package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;


public interface CategoryMapper {

    /**
     * 插入分类数据
     * @param category
     */
    @AutoFill(OperationType.INSERT)
    @Insert("insert into category values (null, #{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Category category);

    Page<Category> pageQuery(String name, Integer type);

    @Delete("delete from category where id = #{id}")
    void deleteById(long id);

    @AutoFill(OperationType.UPDATE)
    void update(Category category);

    List<Category> list(Integer type);


    /**
     * 通过分类id获取分类信息
     * @param categoryId
     * @return
     */
    Category getById(Long categoryId);
}
